//---------------------------------------------------------------------------

#ifndef CDBEditEuroH
#define CDBEditEuroH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Controls.hpp>
#include <Classes.hpp>
#include <Forms.hpp>
#include "CDBEdit.h"
#include <DBCtrls.hpp>
#include <Mask.hpp>
#include <StdCtrls.hpp>
#include "CtrlDB.h"
#include <Buttons.hpp>
#include "CEditNum.h"
//---------------------------------------------------------------------------
enum TypeMonnaieDB { edbEuro, edbFranc };
//---------------------------------------------------------------------------

class PACKAGE_CTRLDB CDBEditEuro : public CDBEdit
{
private:
    TSpeedButton    *BouttonAff; //Bouton pour afficher la deuxieme fenetre
    TForm           *FormPopUp; //Forme surgissante pour afficher et saisir les francs
    TPanel          *PanelAff; //Panel pour afficher en style combobox
    TLabel          *lAffFranc; //Affichage du montant en francs
    TPanel          *PanelBas; //Panel pour afficher le bas de la form
    CEditNum        *EditFranc; //Saisie du montant en francs
    TLabel          *lAffSymboleFr; //Affichage du symbole des francs a cote de la saisie
    TShape          *sRectTour; //Objet pour dessiner un rectangle autour de FormPopUp

    bool bFirstAff;
    bool m_bVisuBouton;
    enum TypeMonnaieDB    m_TypeMonnaie;

    virtual void __fastcall SetParent(TWinControl* AParent);
    void __fastcall SetVisuBouton( bool bVisu);

    //Fonction util diverse
    double __fastcall ConvFrToEu (double dVal, bool bFrancs);
    AnsiString __fastcall AddSeparMillier( AnsiString asText);
//    TPoint* __fastcall RecupCoordForm(TWinControl *cParent, TPoint *point);
//    TWinControl* __fastcall RecupFormParent(TWinControl *cParent);

    //Fondtion pas creer ou détruire les objets utilisés
    void __fastcall newBouttonAff(void);
    void __fastcall detruitBouttonAff(void);
    void __fastcall newPopUp(void);
    void __fastcall detruitPopUp(void);

    //Evenement des composants
    void __fastcall BouttonAffClick( TObject *pSender);
    void __fastcall FormPopUpOnDeactivate( TObject *pSender);
    void __fastcall EditFrancKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);

    TNotifyEvent FOnShowPopUp;
    TNotifyEvent FOnHidePopUp;

    virtual __fastcall ~CDBEditEuro ();

protected:
    void __fastcall WMWindowPosChanged( TWMWindowPosChanged &Msg);
    void __fastcall WMChar(Messages::TWMChar& Msg);    
    void __fastcall WMKillFocus( TWMKillFocus &Msg);
    void __fastcall WMSetFocus( TWMSetFocus &Msg);

    BEGIN_MESSAGE_MAP
        MESSAGE_HANDLER( WM_WINDOWPOSCHANGED, TWMWindowPosChanged, WMWindowPosChanged)
        MESSAGE_HANDLER( WM_KILLFOCUS, TWMKillFocus, WMKillFocus)
        MESSAGE_HANDLER( WM_SETFOCUS, TWMSetFocus, WMSetFocus)
        MESSAGE_HANDLER( WM_CHAR, TWMChar, WMChar)
    END_MESSAGE_MAP(CDBEdit)

    void __fastcall ShowPopUp( void );
    void __fastcall HidePopUp( void );
    
public:
    __fastcall CDBEditEuro(TComponent* Owner);
__published:
    __property bool VisuBouton      = { read=m_bVisuBouton, write=SetVisuBouton , default=true};
    __property enum TypeMonnaieDB TypeMonnaie = { read=m_TypeMonnaie, write=m_TypeMonnaie, default = edbEuro};

    __property TNotifyEvent OnShowPopUp = {read=FOnShowPopUp, write=FOnShowPopUp};
    __property TNotifyEvent OnHidePopUp = {read=FOnHidePopUp, write=FOnHidePopUp};

};
//---------------------------------------------------------------------------
#endif
